{template 'common/header'}
{php echo $this -> set_tabbar($action, 2);}
{if $operation == 'display'}
<div class="main">
    <form action="" method="post" class="form-horizontal form">
        <div class="panel panel-default">
            <div class="panel-body">
                <a class="btn btn-primary" href="{php echo $this->createWebUrl('store', array('op' => 'post'))}"><i class="fa fa-plus"></i> 添加门店</a>
                <a class="btn btn-primary" href="{php echo $this->createWebUrl('storelog')}">总消费记录</a>
            </div>
        </div>
        <div class="panel panel-default">
            <div class="table-responsive panel-body">
                <table class="table table-hover">
                    <thead class="navbar-inner">
                    <tr>
                        <th style="width:10%">显示顺序</th>
                        <th style="width:35%">名称</th>
                        <th style="width:15%">电话</th>
                        <th style="width:15%;">地址</th>
                        <th style="width:10%;">是否显示</th>
                        <th style="width:15%;">编辑/删除/记录</th>
                    </tr>
                    </thead>
                    <tbody id="level-list">
                    {loop $stores $store}
                    <tr>
                        <td><input type="text" class="form-control" name="displayorder[{$store['id']}]" value="{$store['displayorder']}"></td>
                        <td>{$store['title']}</td>
                        <td>{$store['tel']}</td>
                        <td>{$store['address']}</td>
                        <td>{if $store['is_show']==1}
                            <span class="label label-success">显示</span>
                            {else}
                            <span class="label label-danger">隐藏</span>
                            {/if}
                        </td>
                        <td>
                            <a class="btn btn-default btn-sm" href="{php echo $this->createWebUrl('store', array('op' => 'post', 'id' => $store['id']))}"><i class="fa fa-pencil"></i></a>
                            <a class="btn btn-default btn-sm" onclick="return confirm('确认删除吗？');return false;" href="{php echo $this->createWebUrl('store', array('op' => 'delete', 'id' => $store['id']))}"><i class="fa fa-times"></i></a>
                            <a class="btn btn-default btn-sm" title="消费日志" href="{php echo $this->createWebUrl('storelog', array('op' => 'post', 'storeid' => $store['id']))}"><i class="fa fa-bar-chart"></i></a>
                        </td>
                    </tr>
                    {/loop}
                    </tbody>
                    <tfoot>
                    <tr>
                        <td colspan="7">
                            <input name="submit" type="submit" class="btn btn-primary" value="批量排序">
                            <input type="hidden" name="token" value="{$_W['token']}" />
                        </td>
                    </tr>
                    </tfoot>
                </table>
            </div>
        </div>
    </form>
    {$pager}
</div>
{elseif $operation == 'post'}
<div class="main">
    <form action="" method="post" onsubmit="return check();" class="form-horizontal form" enctype="multipart/form-data">
        <div class="panel panel-default">
            <div class="panel-heading">
                {$title}
            </div>
            <div class="panel-body">
                <div class="form-group">
                    <label class="col-xs-12 col-sm-3 col-md-2 control-label">是否显示</label>
                    <div class="col-sm-9">
                        <label class="radio-inline">
                            <input type="radio" name="is_show" value="1" {if empty($reply)}checked="checked"{elseif $reply['is_show']==1}checked="checked"{/if} />显示
                        </label>
                        <label class="radio-inline">
                            <input type="radio" name="is_show" value="0" {if !empty($reply) &&  $reply['is_show']==0}checked="checked"{/if} />隐藏
                        </label>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-xs-12 col-sm-3 col-md-2 control-label">门店名称</label>
                    <div class="col-sm-9">
                        <input type="text" name="title" value="{$reply['title']}" id="title" class="form-control" />
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-xs-12 col-sm-3 col-md-2 control-label">门店电话</label>
                    <div class="col-sm-9">
                        <input type="text" name="tel" id="tel" value="{$reply['tel']}" class="form-control">
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-xs-12 col-sm-3 col-md-2 control-label">门店地址</label>
                    <div class="col-sm-9">
                        <input type="text" name="address" id="address" value="{$reply['address']}" class="form-control">
                    </div>
                </div>
                <!--<div class="form-group">-->
                    <!--<label class="col-xs-12 col-sm-3 col-md-2 control-label">门店简介</label>-->
                    <!--<div class="col-sm-9">-->
                        <!--<textarea class="form-control richtext" name="content" cols="70" id="reply-add-text">{$reply['content']}</textarea>-->
                    <!--</div>-->
                <!--</div>-->
                <!--<div class="form-group">-->
                    <!--<label class="col-xs-12 col-sm-3 col-md-2 control-label">商家所在地区</label>-->

                    <!--<div class="col-sm-3">-->
                        <!--<select name="location_p" id="location_p" class="location form-control"></select>-->
                    <!--</div>-->
                    <!--<div class="col-sm-3">-->
                        <!--<select name="location_c" id="location_c" class="location form-control"></select>-->
                    <!--</div>-->
                    <!--<div class="col-sm-3">-->
                        <!--<select name="location_a" id="location_a" class="location form-control"></select>-->
                    <!--</div>-->
                    <!--<script type="text/javascript" src="../addons/weisrc_icard/template/js/region_select.js"></script>-->
                    <!--<script type="text/javascript">-->
                        <!--var location_p = "{if !empty($reply['location_p'])}{$reply['location_p']}{else}广东省{/if}";-->
                        <!--var location_c = "{if !empty($reply['location_c'])}{$reply['location_c']}{else}汕头市{/if}";-->
                        <!--var location_a = "{if !empty($reply['location_a'])}{$reply['location_a']}{else}龙湖区{/if}";-->
                        <!--new PCAS("location_p", "location_c", "location_a", location_p, location_c, location_a);-->
                    <!--</script>-->
                <!--</div>-->
                <div class="form-group">
                    <label class="col-xs-12 col-sm-3 col-md-2 control-label">坐标</label>
                    <div class="col-sm-9">
                        {php echo tpl_form_field_coordinate('baidumap', $reply)}
                    </div>
                </div>
            </div>
        </div>
        <div class="form-group">
            <div class="col-sm-12">
                <input name="submit" type="submit" value="保存设置" class="btn btn-primary span3">
                <input type="hidden" name="token" value="{$_W['token']}"/>
            </div>
        </div>
    </form>
</div>

<script type="text/javascript">
    function check() {
        if($.trim($('#title').val()) == '') {
            message('没有输入门店名称.', '', 'error');
            return false;
        }
        if($.trim($('#tel').val()) == '') {
            message('没有输入门店电话.', '', 'error');
            return false;
        }
        if($.trim($('#address').val()) == '') {
            message('没有输入门店地址.', '', 'error');
            return false;
        }
        return true;
    }
</script>
{/if}
{template 'common/footer'}
